﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ListenMusic.Models;
using ListenMusic.Models.Reposistory.Public;
using System.ServiceModel;
namespace ListenMusic.Controllers.Public
{
    public class DowloadController : ApplicationController
    {
        //
        // GET: /Dowload/

        
        public DowloadController()
        {
           
        }
        public FileResult DowloadFile(string url)
        {
            try
            {
                var files = _dowload.GetFiles();
                string filename = _dowload.getFileDowload(url, files);
                string[] split = filename.Split('\\');
                string contentType = "application/mp3";
                return File(filename, contentType, split[split.Length - 1]);
            }
            catch (FaultException ex)
            {   
                throw ex;
            }
        }

    }
}
